using UnityEngine;
using System.Collections;


	public class Message
	{
		public enum MessageType{MSG,ATTACK,HIT_SUCCESS,NONE}; 
	
		public MessageType type;
	
		public MonoBehaviour sender = null;
	
		public System.Object[] array;
		
		private Message ()
		{
			type = Message.MessageType.NONE;
		}
		public static Message DefaultMessage(string str)
		{
			Message msg = new Message();
		
			msg.type = Message.MessageType.MSG;
			msg.array = new System.Object[]{str};
		
			return msg;
		}
		public static Message Attack(Skill skill,Attacker atker)
		{
			Message msg = new Message();
		
			msg.type = Message.MessageType.ATTACK;
			msg.array = new System.Object[]{skill,atker};
			msg.sender = atker;
		
			return msg;
		
		}
		public static Message HitSuccess(Skill skill,Defender def)
		{
			Message msg = new Message();
		
			msg.type = Message.MessageType.HIT_SUCCESS;
		
			msg.array = new System.Object[]{skill,def};
			msg.sender = def;
		
			return msg;
			
		}
		public void sendBackward(Message msg)
		{
			
			if(((Attacker)sender) != null)
			{
				sender.gameObject.SendMessage("AllAttacker",msg);
			}else if(((Defender)sender) != null)
			{
				sender.gameObject.SendMessage("AllDefender",msg);
			}else
			{
				// error here
			}
		}
		public static void ALLDefender(Message msg)
		{
			GameObject.Find("InteractionGroup").BroadcastMessage("AllDefender", msg);
		}
		public static void ALLAttacker(Message msg)
		{
			GameObject.Find("InteractionGroup").BroadcastMessage("AllAttacker", msg);
		}
		
}


